package nc.vo.pub.caa.scheduler;

import nc.bs.framework.common.NCLocator;
import nc.bs.logging.Logger;
import nc.bs.pub.clusterscheduler.IJobHandler;
import nc.itf.capub.taskschedule.ICAAJob;
import nc.vo.pub.BusinessException;
import nc.vo.pub.clusterscheduler.IJob;
import nc.vo.pub.clusterscheduler.ITask;

public class CAAJobHandler implements IJobHandler {
	public void executeTask(String taskID, String jobID) throws Exception {
		ICAAJob caa = (ICAAJob) NCLocator.getInstance().lookup(
				ICAAJob.class.getName());
		caa.executeTask(taskID, jobID);
	}

	public IJob[] getAllTimedJobs() {
		return null;
	}

	public ITask[] splitJob(IJob job) {
		if (job == null || !(job instanceof CAAJob)) {
			return null;
		}
		ITask[] tasks = null;
		ICAAJob caa = (ICAAJob) NCLocator.getInstance().lookup(
				ICAAJob.class.getName());
		try {
			tasks = caa.getScheduleTaskArray(job.getJobID());
		} catch (BusinessException e) {
			Logger.error(e.getMessage(), e);
		}
		return tasks;
	}
}